var autodb = require('../../db/auto.db');
var emit = require('../../emit');
var logger = require('../../logger')
var async = require('async');

function onsocket(socket, data) {
    if (data != null){
    let isMusic = data.isMusic ? true : false;
    autodb.gettagtree(isMusic, (err, tree) => {
        if (err) {
            emit.send(socket, "gettaglist", null);
        } else {
            var protocol = isMusic ? 'gettaglist-music' : 'gettaglist-sound';
            emit.send(socket, protocol, tree);
        }
    });
    }
}

module.exports = {
    onsocket
}
